package jiedan

import org.apache.spark.sql.SparkSession

import java.util.Properties

object test {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .master("local[*]")
      .appName("数据清洗")
      .enableHiveSupport()
      .getOrCreate()

    val data=spark.read.format("csv")
      .option("header", "true")
      .option("delimiter", ",")
      .load("hdfs://192.168.40.110:9000/tmp/lu9198b2_yaopinxinxi.csv")

    val connect = new Properties()
    connect.setProperty("user", "root")
    connect.setProperty("password", "123456")
    connect.setProperty("driver", "com.mysql.jdbc.Driver")

    data.write.format("overwrite")
      .jdbc("jdbc:mysql://192.168.40.110:3306/test?useSSL=false","lu9198b2_yaopinxinxi",connect)



    spark.close()
  }

}
